#ifndef __BS_COMMON_H_
#define __BS_COMMON_H_

#include <iconv.h>
#include "bs_type.h"
#include "bs_error.h"

#define bs_max(a, b) ((a)>=(b) ? (a):(b))
#define bs_min(a, b) ((a) < (b) ? (a):(b))

#define bs_is_num(code)         ('0'<=(code) && (code)<='9')
#define bs_is_lowletter(code)   ('a'<=(code) && (code)<='z')
#define bs_is_highletter(code)  ('A'<=(code) && (code)<='Z')
#define bs_is_letter(code)      (bs_is_lowletter(code)||bs_is_highletter(code))
#define bs_is_char(code)        (bs_is_num(code) || bs_is_letter(code))
#define bs_is_space(code)       ((code)==' ' || (code)=='\t' || (code)=='\n')

#ifdef __cplusplus
extern "C"{
#endif

uint64_t atou64(const char* str);
state_t convert(const char *fromset, const char *toset, char *from,size_t from_len, char *to,size_t to_len);

#ifdef __cplusplus
}
#endif

#endif
